package com.ttg.web.dao.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ttg.model.mapper.MctLastGradeBakMapper;
import com.ttg.model.pojo.MctLastGradeBak;
import com.ttg.web.dao.MctLastGradeBakDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MctLastGradeBakDaoImpl extends ServiceImpl<MctLastGradeBakMapper, MctLastGradeBak> implements MctLastGradeBakDao {

    @Override
    public void truncateOldRecords() {
        baseMapper.truncateOldRecords();
    }

    @Override
    public void mctBak(Integer date) {
        baseMapper.mctBak(date);
    }

    @Override
    public MctLastGradeBak checkBakResultByDate(Integer date) {
        LambdaQueryWrapper<MctLastGradeBak> wrapper = new LambdaQueryWrapper<>();
        wrapper.gt(MctLastGradeBak::getBakDate,date)
                .last("limit 1");
        return getOne(wrapper);
    }
}
